// 笔试强训：最长回文子序列

#include <iostream>
#include <vector>
using namespace std;

int main() {
    string str; cin >> str;
    int n = str.size();
    vector<vector<int>> dp(n, vector<int>(n, 0));
    for(int i = 0; i < n; i++)
        dp[i][i] = 1;
    for(int left = n - 2; left >= 0; left--)
    {
        for(int right = left + 1; right < n; right++)
        {
            if(str[left] == str[right])
                dp[left][right] = dp[left + 1][right - 1] + 2;
            else if(left + 1 == right)
                dp[left][right] = 1;
            else
                dp[left][right] = max(dp[left + 1][right], dp[left][right - 1]);
        }
    }
    cout << dp[0][n - 1] << endl;
}